package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/shop")
@Slf4j
@RequiredArgsConstructor
@Api(tags = "店铺相关接口")

public class ShopController {

    private final RedisTemplate redisTemplate;
    @PutMapping("/status")
    @ApiOperation("修改店铺营业状态")
    public Result<String> setStatus(Integer status) {
        redisTemplate.opsForValue().set("SHOP_STATUS",status);
        return Result.success();
    }
    @ApiOperation("获取店铺营业状态")
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        return Result.success(status);
    }
}
